package com.trailer.base.utils;

import android.util.Log;

import java.util.Random;

/**
 * on 2022/9/24
 */
public class ParamUtils {

    /**
     * 获取一条随机字符串
     * @param length
     * @return
     */
    public static String getRandomString(int length) { //length表示生成字符串的长度
        String base = "abcdefghijklmnopqrstuvwxyz0123456789";
        Random random = new Random();
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < length; i++) {
            int number = random.nextInt(base.length());
            sb.append(base.charAt(number));
        }
        Log.e("--shy", "getRandomString: " + sb.toString());
        return sb.toString();
    }

    private void randomTest() {
        Random random = new Random();
        Log.e("--shy", "randomTest1: " + random.nextLong());
        Log.e("--shy", "randomTest2: " + random.nextBoolean());
        Log.e("--shy", "randomTest3: " + random.nextDouble());
        Log.e("--shy", "randomTest4: " + random.nextFloat());
        Log.e("--shy", "randomTest5: " + random.nextGaussian());//可以产生服从高斯分布的随机数
        Log.e("--shy", "randomTest6: " + random.nextInt());
        //范围内的随机数
        int min = 10;
        int max = 99;
        int num = random.nextInt(max - min + 1) + min;
        Log.e("--shy", "randomTest7: " + num);
    }



}
